package 剑指Offer1;

public class _30和为s的两个数字 {
    public int[] twoSum(int[] nums, int target) {
        if(nums == null || nums.length == 0) return new int[0];
        int i=0,j = nums.length - 1;
        while(i<j){
            int sum = nums[i] + nums[j];
            if( sum == target){
                return new int[]{nums[i],nums[j]};
            }else if(sum > target){
                j--;
            }else{
                i++;
            }
        }
        return new int[0];
    }
}
